package com.zking.myservlet.view;

import com.zking.dao.ViewDao;
import com.zking.entity.View;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/manage/ViewModify")
public class ViewModify extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //处理请求的编码，解决中文乱码
        request.setCharacterEncoding("utf-8");
        //处理响应的编码 ，解决中文乱码
        response.setContentType("text/html;charset=utf-8");

        System.out.println("ViewModify===进来");

//        //接收参数(来自jsp的）
        Integer uuid=Integer.parseInt(request.getParameter("uuid"));
        String userId=request.getParameter("userId");
        String content=request.getParameter("content");
        String review=request.getParameter("review");
        String username=request.getParameter("username");

//        View view = new View(content,review,"" ,username,userId,uuid);
//        boolean flag = ViewDao.updateViews(view);
//        if(flag){
//            request.getRequestDispatcher("guestbook-modify.jsp").forward(request, response);
//        }
        //前后端参数，第一个为前端页面参数，第二个为后端
        request.setAttribute("uuid",uuid);
        request.setAttribute("userId",userId);
        request.setAttribute("content",content);
        request.setAttribute("review",review);
        request.setAttribute("username",username);

        request.getRequestDispatcher("guestbook-modify.jsp").forward(request, response);



        //设置要传递的变量





    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}